<?php

error_reporting(E_ALL);

require_once '../models/draco.php';

$connection = mysql_connect('localhost','root','du153') or die(mysql_error());
mysql_select_db('draco');

draco::main('../ress.json', '../buildings');

$ressources = draco::getRessources();
$buildings = draco::getBuildings();

$date = time();

foreach($buildings as $value) {
        $level = $value->getLevelUntilApproxPrice(1000000);
        $profit = $value->getHalfLevelProfit();
        
        mysql_query("INSERT INTO eff_log (saveTime, building, efficiency) VALUES ({$date}, '{$value->getName()}', {$profit})") or die(mysql_error());        
}

echo "successfull";

mysql_close($connection);
?>